<template>
  <div class="list">
    <div
     class="item"
     v-for="(item, index) of list"
     :key = index
     >
      <div class="item-title b-1px-b">
        <div class="item-title-icon">{{item.title}}</div>
      </div>
      <!--1.重点, 组件递归, :list 将item.children赋给变量list, 然后再调用上面的方法-->
      <div v-if="item.children" class="item-children">
        <detail-list :list="item.children"></detail-list>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'DetailList',
  props: {
    list: Array
  },
  data () {
    return {
    }
  }
}
</script>

<style lang="stylus" scoped>
  .item-title
    line-height .8rem
    font-size .32rem
    padding 0 .2rem
    .item-title-icon
      position relative
      left .06rem
      top .06rem
      display inline-block
      margin-right .1rem
      background: url(/images/common/detail.png) 0 -.6rem no-repeat
      background-size 0.48rem 5.12rem
      background-origin padding-box  /*相对于背景图片的距离 = padding值, 或者说背景图片起始位置*/
      padding 0 .45rem
  .item-children
    padding 0 .2rem
</style>
